<template>
  <div id="classtime_manage" class="container">
    <div class="content">
      <!-- <div class="title">消息管理</div> -->
      <div class="panel">
        <el-form label-width="240px" style="margin-top:0.44rem;">
          <el-form-item label="欠费提醒设置">
            <el-switch
              v-model="messageData.arrearsRemind"
              :active-value="1"
              :inactive-value="0"
              @change="setMessage"
              style="margin-left:0.4rem;"
            ></el-switch>
            <span style="margin-left:0.4rem;font-size:0.16rem;">显示所有欠费学员</span>
          </el-form-item>
          <el-form-item label="续费提醒设置">
            <div>
              <el-switch
                v-model="messageData.renewRemind"
                :active-value="1"
                :inactive-value="0"
                 @change="setMessage"
                style="margin-left:0.4rem;"
              ></el-switch>
              <span style="margin-left:0.4rem;font-size:0.16rem;">显示剩余课时不足&nbsp;</span>
              <el-input-number
                ref="syllabusNum"
                size="small"
                controls-position="right"
                class="newclassroomNumber"
                style="width:12%;"
                 @change="setMessage"
                v-model="messageData.renewHour"
                :min="0"
                :max="999"
              ></el-input-number>
              <span style="margin-left:0.1rem;font-size:0.16rem;">课时的所有学员</span>
            </div>
            <div style="margin-top:0.2rem;">
              <span style="margin-left:1.2rem;font-size:0.16rem;">显示剩余天数不足&nbsp;</span>
              <el-input-number
                ref="syllabusNum"
                size="small"
                controls-position="right"
                class="newclassroomNumber"
                style="width:12%;"
                 @change="setMessage"
                v-model="messageData.renewDay"
                :min="0"
                :max="999"
              ></el-input-number>
              <span style="margin-left:0.1rem;font-size:0.16rem;">天的所有学员</span>
            </div>
          </el-form-item>
          <el-form-item label="申请提醒">
            <el-switch
              v-model="messageData.applyRemind"
              :active-value="1"
              :inactive-value="0"
               @change="setMessage"
              style="margin-left:0.4rem;"
            ></el-switch>
            <span style="margin-left:0.4rem;font-size:0.16rem;">显示所有请假、补课、续报申请</span>
          </el-form-item>
          <el-form-item label="任务提醒">
            <el-switch
              v-model="messageData.taskRemind"
              :active-value="1"
              :inactive-value="0"
               @change="setMessage"
              style="margin-left:0.4rem;"
            ></el-switch>
            <span style="margin-left:0.4rem;font-size:0.16rem;">待跟进任务添加到日程提醒</span>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
let vm;
let user;
export default {
  data() {
    return {
      messageData: {
        arrearsRemind: 0, //欠费
        renewRemind: 0, //续费
        applyRemind: 0, //申请
        taskRemind: 0, //任务
        renewHour: 0, //续费，不足课时
        renewDay: 0 //续费，不足天数
      }
    };
  },
  components: {},
  methods: {
    campusChange: function(campusId) {
      this.initData();
    },
    initData() {
      let paras = {
        campusId: this.$store.state.campusId
      };
      api.campusMsgGet(paras).then(function(data) {
        if (data.resultCode == 2000) {
          vm.messageData = data.setting;
        } else {
          vm.$message.error(data.message);
        }
      });
    },
    setMessage(){
       api.campusMsgSet(vm.messageData).then(function(data) {
        if (data.resultCode == 2000) {
          vm.$message({
              message: "修改成功",
              type: "success"
            });
        } else {
          vm.$message.error(data.message);
        }
      });
    }
  },
  mounted() {
    vm = this;
    user = tool.getItem(lsKey.user, true); //得到当前用户信息
    let dicdata = tool.getItem(lsKey.dict, true);
    vm.initData();
  },
  computed: {}
};
</script>

<style lang="scss">
#classtime_manage {
  .el-input__inner {
    border-radius: 0.08rem;
    font-size: 0.16rem;
    color: #666666;
    height: 0.36rem;
    line-height: 0.36rem;
  }
  .el-input__icon {
    line-height: 0.36rem;
  }
  .el-form-item__label {
    font-size: 0.18rem;
  }
  .el-form-item {
    margin-bottom: 0.44rem;
  }

  .input_search {
    .el-input__inner {
      background-color: rgb(247, 248, 250);
    }
  }
}
</style>
<style scoped src="@/style/clue_manage/clue_manage.css"></style>
<style scoped>
</style>